/**
 * Created by Administrator on 2017/3/21.
 */
import React, {Component} from 'react';
import {Form, Input, Radio, Select, Switch, DatePicker,InputNumber  } from 'antd';
import {connect} from 'dva';
import moment from 'moment'
import request from '@/utils/request';
const FormItem = Form.Item;
const { TextArea } = Input;
const RadioGroup = Radio.Group;
const Option = Select.Option;
class AddPoliciesForm extends Component {
  constructor(props) {
    super(props);
    this.state = {
      type:'1',
      distributors:[],
      value: [],
    };
  }

  componentDidMount() {
  }
  handleChange = value => {
    console.log(value)
    this.setState({
      value,
      data: [],
    },function () {
    });

  };
  render() {
    const formItemLayoutWithLabel = {
      labelCol: {
        xs: {span: 24},
        sm: {span: 6},
      },
      wrapperCol: {
        xs: {span: 24},
        sm: {span: 15},
      }
    };

    const {getFieldDecorator} = this.props.form;
    return (
      <div>
        <Form onSubmit={this.handleSubmit}>
          <FormItem
            {...formItemLayoutWithLabel}
            label={(
              <span>
               设备ID
            </span>
            )}
          >
            {getFieldDecorator('device_id', {
              initialValue: '',
              rules: [{ required: true, message: '请输入设备ID' }],
            })(
              <Input />
            )}
          </FormItem>
          <FormItem
            {...formItemLayoutWithLabel}
            label={(
              <span>
               类型
            </span>
            )}
          >
            {getFieldDecorator('type', {
              initialValue: '1',
              rules: [{ required: true, message: '请选择类型' }],
            })(
              <RadioGroup onChange={(e)=>{
                console.log(e)
                this.setState({
                  type:e.target.value
                })
              }}>
                <Radio value="1">读</Radio>
                <Radio value="2">写</Radio>
                <Radio value="3">执行</Radio>
                <Radio value="4">资源发现</Radio>
              </RadioGroup>
            )}
          </FormItem>
          <FormItem
            {...formItemLayoutWithLabel}
            label={(
              <span>
               对象ID
            </span>
            )}
          >
            {getFieldDecorator('object_id', {
              initialValue: '',
              rules: [{ required: true, message: '请输入对象ID' }],
            })(
              <Input />
            )}
          </FormItem>
          <FormItem
            {...formItemLayoutWithLabel}
            label={(
              <span>
               实例iID
            </span>
            )}
          >
            {getFieldDecorator('instance_id', {
              initialValue: '',
            })(
              <Input />
            )}
          </FormItem>

          <FormItem
            {...formItemLayoutWithLabel}
            label={(
              <span>
               资源ID
            </span>
            )}
          >
            {getFieldDecorator('resource_id', {
              initialValue: '',
            })(
              <Input />
            )}
          </FormItem>
          <FormItem
            {...formItemLayoutWithLabel}
            label={(
              <span>
               项目名称
            </span>
            )}
          >
            {getFieldDecorator('project_name', {
              initialValue: '',
              rules: [{ required: true, message: '请输入项目名称' }],
            })(
              <Input />
            )}
          </FormItem>
          <FormItem
            {...formItemLayoutWithLabel}
            label={(
              <span>
               超时时间
            </span>
            )}
          >
            {getFieldDecorator('title', {
              initialValue: 25,
            })(
              <InputNumber />
            )}
          </FormItem>
          <FormItem
            {...formItemLayoutWithLabel}
            label={(
              <span>
               内容
            </span>
            )}
          >
            {getFieldDecorator('content', {
              initialValue: '',
              rules: [{ required: true, message: '请输入内容' }],
            })(
              <TextArea rows={4} />,
            )}
          </FormItem>
        </Form>
      </div>
    );
  }
}

const AddPoliciesFormWrap = Form.create()(AddPoliciesForm);
export default connect()(AddPoliciesFormWrap);


